home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / lynx-2.4 / WWW / Library / Implementation / HTGroup.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-28  |  5.5 KB  |  190 lines

  1. /*                                    GROUP FILE ROUTINES
  2.                                              
  3.  */
  4.  
  5. #ifndef HTGROUP_H
  6. #define HTGROUP_H
  7.  
  8. #ifndef HTUTILS_H
  9. #include "HTUtils.h"
  10. #endif /* HTUTILS_H */
  11. #include "HTList.h"
  12.  
  13. #ifdef SHORT_NAMES
  14. #define HTAApGrD        HTAA_parseGroupDef
  15. #define HTAArGrR        HTAA_resolveGroupReferences
  16. #define HTAApGrD        HTAA_printGroupDef
  17. #define HTAAGD_d        GroupDef_delete
  18. #define HTAAuIIG        HTAA_userAndInetInGroup
  19. #endif /* SHORT_NAMES */
  20.  
  21. typedef HTList GroupDefList;
  22. typedef HTList ItemList;
  23.  
  24. typedef struct {
  25.     char *      group_name;
  26.     ItemList *  item_list;
  27. } GroupDef;
  28.  
  29.  
  30. /*
  31. ** Access Authorization failure reasons
  32. */
  33. typedef enum {
  34.     HTAA_OK,            /* 200 OK                               */
  35.     HTAA_OK_GATEWAY,    /* 200 OK, acting as a gateway          */
  36.     HTAA_NO_AUTH,       /* 401 Unauthorized, not authenticated  */
  37.     HTAA_NOT_MEMBER,    /* 401 Unauthorized, not authorized     */
  38.     HTAA_IP_MASK,       /* 403 Forbidden by IP mask             */
  39.     HTAA_BY_RULE,       /* 403 Forbidden by rule                */
  40.     HTAA_NO_ACL,        /* 403 Forbidden, ACL non-existent      */
  41.     HTAA_NO_ENTRY,      /* 403 Forbidden, no ACL entry          */
  42.     HTAA_SETUP_ERROR,   /* 403 Forbidden, server setup error    */
  43.     HTAA_DOTDOT,        /* 403 Forbidden, URL with /../ illegal */
  44.     HTAA_HTBIN,         /* 403 Forbidden, /htbin not enabled    */
  45.     HTAA_NOT_FOUND      /* 404 Not found, or read protected     */
  46. } HTAAFailReasonType;
  47.  
  48. /*
  49.  
  50. Group definition grammar
  51.  
  52.   string
  53.                          "sequence of alphanumeric characters"
  54.                          
  55.   user_name
  56.                          string
  57.                          
  58.   group_name
  59.                          string
  60.                          
  61.   group_ref
  62.                          group_name
  63.                          
  64.   user_def
  65.                          user_name | group_ref
  66.                          
  67.   user_def_list
  68.                            user_def { ',' user_def }
  69.                          
  70.   user_part
  71.                          user_def | '(' user_def_list ')'
  72.                          
  73.   templ
  74.                          
  75.                          "sequence of alphanumeric characters and '*'s"
  76.                          
  77.   ip_number_mask
  78.                          templ '.' templ '.' templ '.' templ
  79.                          
  80.   domain_name_mask
  81.                          templ { '.' templ }
  82.                          
  83.   address
  84.                          
  85.                          ip_number_mask | domain_name_mask
  86.                          
  87.   address_def
  88.                          
  89.                          address
  90.                          
  91.   address_def_list
  92.                          address_def { ',' address_def }
  93.                          
  94.   address_part
  95.                          address_def | '(' address_def_list ')'
  96.                          
  97.   item
  98.                          [user_part] ['@' address_part]
  99.                          
  100.   item_list
  101.                          item { ',' item }
  102.                          
  103.   group_def
  104.                          item_list
  105.                          
  106.   group_decl
  107.                          group_name ':' group_def
  108.                          
  109.   PARSE GROUP DEFINITION
  110.   
  111.  */
  112.  
  113. PUBLIC GroupDef *HTAA_parseGroupDef PARAMS((FILE * fp));
  114. /*
  115.  
  116. Fill in Pointers to referenced Group Definitions in a Group Definition
  117.  
  118.    References to groups (by their name) are resolved from group_def_list and pointers to
  119.    those structures are added to group_def.
  120.    
  121.  */
  122.  
  123. PUBLIC void HTAA_resolveGroupReferences PARAMS((GroupDef *     group_def,
  124.                                                 GroupDefList * group_def_list));
  125. /*
  126.  
  127. Read Group File (and do caching)
  128.  
  129.    If group file is already in cache returns a pointer to previously read group definition
  130.    list.
  131.    
  132.  */
  133.  
  134. PUBLIC GroupDefList *HTAA_readGroupFile PARAMS((CONST char * filename));
  135. /*
  136.  
  137. Delete Group Definition
  138.  
  139.    Groups in cache should never be freed by this function. This should only be used to
  140.    free group definitions read by HTAA_parseGroupDef.
  141.    
  142.  */
  143.  
  144. PUBLIC void GroupDef_delete PARAMS((GroupDef * group_def));
  145. /*
  146.  
  147. Print Out Group Definition (for trace purposes)
  148.  
  149.  */
  150.  
  151. PUBLIC void HTAA_printGroupDef PARAMS((GroupDef * group_def));
  152. /*
  153.  
  154. Does a User Belong to a Given Set of Groups
  155.  
  156.    This function checks both the username and the internet address.
  157.    
  158.  */
  159.  
  160. /* PUBLIC                                       HTAA_userAndInetInGroup()
  161. **              CHECK IF USER BELONGS TO TO A GIVEN GROUP
  162. **              AND THAT THE CONNECTION COMES FROM AN
  163. **              ADDRESS THAT IS ALLOWED BY THAT GROUP
  164. ** ON ENTRY:
  165. **      group           the group definition structure.
  166. **      username        connecting user.
  167. **      ip_number       browser host IP number, optional.
  168. **      ip_name         browser host IP name, optional.
  169. **                      However, one of ip_number or ip_name
  170. **                      must be given.
  171. ** ON EXIT:
  172. **      returns         HTAA_IP_MASK, if IP address mask was
  173. **                      reason for failing.
  174. **                      HTAA_NOT_MEMBER, if user does not belong
  175. **                      to the group.
  176. **                      HTAA_OK if both IP address and user are ok.
  177. */
  178. PUBLIC HTAAFailReasonType HTAA_userAndInetInGroup PARAMS((GroupDef * group,
  179.                                                           char *     username,
  180.                                                           char *     ip_number,
  181.                                                           char *     ip_name));
  182. /*
  183.  
  184.  */
  185.  
  186. #endif /* not HTGROUP_H */
  187. /*
  188.  
  189.    End of file HTGroup.h.  */
  190.